package com.stox.services.data.provider.repository.file;

import com.stox.services.core.repository.AbstractCachingFileRepository;
import com.stox.services.data.provider.repository.ExchangeRepository;
import com.stox.shared.core.model.Exchange;

public class ExchangeFileRepository extends AbstractCachingFileRepository<Exchange> implements ExchangeRepository{

	public static final ExchangeFileRepository INSTANCE = new ExchangeFileRepository();
	
	private ExchangeFileRepository() {
		super("exchange");
	}
	
	@Override
	public Exchange deserialize(String text) {
		return new Exchange(text);
	}

	@Override
	public String serialize(Exchange entity) {
		return entity.toString();
	}
	
	@Override
	public void saveAndFlush(Exchange exchange) {
		saveOrUpdate(exchange);
		commit();
	}

}
